#include <stdio.h>
int main()
{
    char cmd[1024];
    char *str = "find | grep 'kang'";
    //char *str = "kang";
    int ret;
    FILE *fp;
    
    sprintf(cmd, "echo '%s'", str);
    printf("CMD : %s\n", cmd);
    ret = system(cmd);
    printf("result : %d\n", ret);

    /*
    fp = fopen("/tmp/log", "w");
    fprintf(fp, "%s", str);
    fclose(fp);
    */
    if( (fp = popen("xclip -i -selection clipboard", "w")) )
        {
            fprintf(fp, "%s", str);
            pclose(fp);
        }
    else
        printf("popen error \n");

    //echo -n "hello" | xclip -i -selection clipboard
    return 0;
}
